{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Guess Numbers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #array"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数组"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: game"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #猜数字"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>小A 和 小B 在玩猜数字。小B 每次从 1, 2, 3 中随机选择一个，小A 每次也从 1, 2, 3 中选择一个猜。他们一共进行三次这个游戏，请返回 小A 猜对了几次？</p>\n",
    "\n",
    "<p>输入的<code>guess</code>数组为 小A 每次的猜测，<code>answer</code>数组为 小B 每次的选择。<code>guess</code>和<code>answer</code>的长度都等于3。</p>\n",
    "\n",
    "<p> </p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>guess = [1,2,3], answer = [1,2,3]\n",
    "<strong>输出：</strong>3\n",
    "<strong>解释：</strong>小A 每次都猜对了。</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>guess = [2,2,3], answer = [3,2,1]\n",
    "<strong>输出：</strong>1\n",
    "<strong>解释：</strong>小A 只猜对了第二次。</pre>\n",
    "\n",
    "<p> </p>\n",
    "\n",
    "<p><strong>限制：</strong></p>\n",
    "\n",
    "<ol>\n",
    "\t<li><code>guess</code> 的长度 = 3</li>\n",
    "\t<li><code>answer</code> 的长度 = 3</li>\n",
    "\t<li><code>guess</code> 的元素取值为 <code>{1, 2, 3}</code> 之一。</li>\n",
    "\t<li><code>answer</code> 的元素取值为 <code>{1, 2, 3}</code> 之一。</li>\n",
    "</ol>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [guess-numbers](https://leetcode.cn/problems/guess-numbers/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [guess-numbers](https://leetcode.cn/problems/guess-numbers/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['[1,2,3]\\n[1,2,3]', '[2,2,3]\\n[3,2,1]']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        n, ans = len(answer), 0\n",
    "        for i in range(n):\n",
    "            if answer[i] == guess[i]:\n",
    "                ans += 1\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum(g == a for g, a in zip(guess, answer))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum(guess[i] == answer[i] for i in range(len(guess)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        #测试题解\n",
    "        return ( guess[ 0 ] == answer[ 0 ] ) + ( guess[ 1 ] == answer[ 1 ] ) + ( guess[ 2 ] == answer[ 2 ] )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        n=0\n",
    "        for i in range(3):\n",
    "            if guess[i]==answer[i]:\n",
    "                n+=1\n",
    "        return n\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        total=0\n",
    "        for i in range(3):\n",
    "            if guess[i]==answer[i]:\n",
    "                total+=1\n",
    "        return total        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        sum = 0\n",
    "        for i in range(0,3):\n",
    "            if guess[i] == answer[i]:\n",
    "                sum += 1\n",
    "        return sum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        counter = 0\n",
    "        for i in range(0,len(answer)):\n",
    "            if answer[i] == guess[i]:\n",
    "                counter += 1\n",
    "            else:\n",
    "                pass\n",
    "        \n",
    "        return counter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        ans = 0\n",
    "        for i in range(0, 3):\n",
    "            if guess[i] == answer[i]:\n",
    "                ans += 1\n",
    "            else:\n",
    "                ans += 0\n",
    "\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        s=0\n",
    "        for i in range(3):\n",
    "            if(guess[i]==answer[i]):\n",
    "                s+=1\n",
    "        return s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        s=0\n",
    "        for i in range(0,3):\n",
    "            if (guess[i]==answer[i]):\n",
    "                s=s+1\n",
    "        return s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        result=0\n",
    "        for i in range(len(guess)):           \n",
    "                if guess[i]==answer[i]:\n",
    "                    result+=1\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        x=0\n",
    "        sum=0\n",
    "        for i in guess:\n",
    "            if guess[x]==answer[x]:\n",
    "                sum+=1\n",
    "            x=x+1\n",
    "        return sum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        ans = 0\n",
    "        for i in range(0, 3):\n",
    "            if guess[i] == answer[i]:\n",
    "                ans += 1\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        a = 0\n",
    "        for i in range(3):\n",
    "            if guess[i] == answer[i]:\n",
    "                a+=1\n",
    "        return a\n",
    "            \n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum(guess[i]==answer[i] for i in range(len(answer)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        a = 0\n",
    "        for i in range(0, 3):\n",
    "            if guess[i] == answer[i]:\n",
    "                a += 1\n",
    "        return a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        sum = 0\n",
    "        for i in range (3):\n",
    "            if guess[i]==answer[i]:\n",
    "                sum+=1\n",
    "        return sum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        sum = 0\n",
    "        for i in range(3):\n",
    "            if guess[i] == answer[i]:\n",
    "                sum = sum + 1\n",
    "        return sum\n",
    "                \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        n = 0\n",
    "        for i in range(3):\n",
    "            if guess[i] == answer[i]:\n",
    "                n += 1\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        count=0\n",
    "        for i in range(3):\n",
    "            if guess[i]==answer[i]:\n",
    "                count+=1\n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum(x==y for x,y in zip(guess, answer))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return (guess[0] == answer[0]) + (guess[1] == answer[1]) + (guess[2] == answer[2])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:return sum(guess[i]==answer[i]for i in range(3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        count = 0\n",
    "        for i in range(3):\n",
    "            if guess[i] == answer[i]:\n",
    "                count += 1\n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum(guess[i]==answer[i] for i in range(3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum(1 if a==b else 0 for a,b in zip(guess,answer))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        a = 0\n",
    "        if guess[0] == answer[0]:\n",
    "            a = a + 1\n",
    "        if guess[1] == answer[1]:\n",
    "            a = a + 1\n",
    "        if guess[2] == answer[2]:\n",
    "            a = a + 1\n",
    "        return a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        true = 0\n",
    "        for i in range(3):\n",
    "            if guess[i] == answer[i]:\n",
    "                true += 1\n",
    "        return true"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum((1 if guess[i] == answer[i] else 0) for i in range(3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int])-> int:\n",
    "        count=0\n",
    "        for i in range(len(guess)):\n",
    "          if guess[i]==answer[i]:\n",
    "             count+=1\n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        res = 0\n",
    "        for i in range(len(guess)):\n",
    "            if guess[i]==answer[i]:\n",
    "                res += 1\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        count = 0\n",
    "        for i in range(len(guess)):\n",
    "            if(guess[i]==answer[i]):\n",
    "                count = count+1\n",
    "            else:\n",
    "                continue\n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        a=0\n",
    "        for i in range(len(guess)):\n",
    "            if guess[i]==answer[i]:\n",
    "                a+=1\n",
    "        return a\n",
    "\n",
    "  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        cnt=0\n",
    "        for i in range(len(guess)):\n",
    "            if guess[i]==answer[i]:\n",
    "                cnt+=1\n",
    "        return cnt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "      cishu = 0\n",
    "      for i in range(0,3):\n",
    "        if guess[i]== answer[i]:\n",
    "           cishu+=1\n",
    "      return cishu "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum(1 for i in range(3) if guess[i] == answer[i])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return (guess[0] == answer[0]) + (guess[1] == answer[1]) + (guess[2] == answer[2])\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        sum = 0\n",
    "        for i in range(3):\n",
    "            if guess[i] == answer[i]:\n",
    "                sum += 1\n",
    "        return sum "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        ans = 0\n",
    "        for a, b in zip(guess, answer):\n",
    "            if a == b:\n",
    "                ans += 1\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum(guess[i] == answer[i] for i in range(len(guess)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum([1 for i in range(3) if guess[i]==answer[i]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:  \n",
    "        sum=0\n",
    "        for i in range(3):\n",
    "                if guess[i]==answer[i]:\n",
    "                    sum+=1\n",
    "        return sum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        ans=0\n",
    "        for i in range(3):\n",
    "            if guess[i]==answer[i]:\n",
    "                ans+=1\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum(g == a for g, a in zip(guess, answer))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        sum=0\n",
    "        for x in range(3):\n",
    "            if guess[x]==answer[x]:\n",
    "                sum+=1\n",
    "        return sum"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        n=0\n",
    "        for i in range(0,len(guess)):\n",
    "            if guess[i]==answer[i]:\n",
    "                n=n+1\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        count = 0\n",
    "        for i in range(3):\n",
    "            if guess[i] == answer[i]:\n",
    "                count += 1\n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        ans = 0\n",
    "        for i in range(len(guess)):\n",
    "            ans += 1 if guess[i] == answer[i] else 0\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        s=0\n",
    "        for i in range(3):\n",
    "            if guess[i]==answer[i]:\n",
    "                s+=1\n",
    "        return(s)\n",
    "        \n",
    "        \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        cnt = 0\n",
    "        for i in range(len(guess)):\n",
    "            if guess[i] == answer[i]:\n",
    "                cnt += 1\n",
    "        return cnt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        a=0\n",
    "        for i in range(len(guess)):\n",
    "            if guess[i]==answer[i]:\n",
    "                a+=1\n",
    "        return a\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        count = 0\n",
    "        for i in range(3):\n",
    "            if guess[i] == answer[i]:\n",
    "                count += 1\n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return (guess[0] == answer[0]) + (guess[1] == answer[1]) + (guess[2] == answer[2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        result = 0\n",
    "        for i in range(0,3):\n",
    "            if guess[i] == answer[i]:\n",
    "                result += 1\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum(a == b for a, b in zip(guess, answer))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum(guess[i]==answer[i] for i in range(len(guess)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        a=0\n",
    "        b=0\n",
    "        right=0\n",
    "        while a<=2:\n",
    "            if guess[a]==answer[b]:\n",
    "                right+=1\n",
    "                a+=1\n",
    "                b+=1\n",
    "            else :\n",
    "                a+=1\n",
    "                b+=1\n",
    "        return(right)\n",
    "        print(right)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        # 记录小A猜对的次数\n",
    "        correct_guesses = 0\n",
    "\n",
    "        # 遍历每一轮游戏\n",
    "        for g, a in zip(guess, answer):\n",
    "            # 判断小A是否猜对了\n",
    "            if g == a:\n",
    "                correct_guesses += 1\n",
    "\n",
    "        return correct_guesses"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        count = 0\n",
    "        for i in range(0,3):\n",
    "            if guess[i] == answer[i]:\n",
    "                count += 1\n",
    "        return count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        count=0\n",
    "        for i in range(3):\n",
    "            if answer[i]==guess[i]:\n",
    "                count+=1\n",
    "        return count\n",
    "\n",
    "  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum([x==y for x, y in zip(guess, answer)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        n = 0\n",
    "        for i in range(3):\n",
    "            if guess[i] == answer[i]: n += 1\n",
    "        return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum([a==b for a,b in zip(guess,answer)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        cnt = 0\n",
    "        for a, b in zip(guess, answer):\n",
    "            if a==b:\n",
    "                cnt += 1\n",
    "        return cnt\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        res=0\n",
    "        for i in range(len(guess)):\n",
    "            if guess[i]==answer[i]:\n",
    "                res+=1\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        result = 0\n",
    "        for i in range(len(answer)):\n",
    "            if answer[i] == guess[i]:\n",
    "                result += 1\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        return sum(guess[i] == answer[i] for i in range(len(guess)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def game(self, guess: List[int], answer: List[int]) -> int:\n",
    "        sum=0\n",
    "        for x in range(3):\n",
    "            if guess[x]==answer[x]:\n",
    "                sum+=1\n",
    "        return sum"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
